package com.epoint.excleutil.Vo;

import com.epoint.excleutil.service.IExcelExportStyler;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * Created by Shinelon on 2017/11/15.
 */
public class ExcelExportStylerDefaultImpl extends AbstractExcelExportStyler implements IExcelExportStyler {
        public ExcelExportStylerDefaultImpl(Workbook workbook)
        {
            super.createStyles(workbook);
        }

        public CellStyle getTitleStyle(short color)
        {
            CellStyle titleStyle = this.workbook.createCellStyle();
            titleStyle.setAlignment(2);
            titleStyle.setVerticalAlignment(1);
            titleStyle.setWrapText(true);
            return titleStyle;
        }

        public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp)
        {
            CellStyle style = workbook.createCellStyle();
            style.setAlignment(2);
            style.setVerticalAlignment(1);
            style.setDataFormat(STRING_FORMAT);
            if (isWarp) {
                style.setWrapText(true);
            }
            return style;
        }

        public CellStyle getHeaderStyle(short color)
        {
            CellStyle titleStyle = this.workbook.createCellStyle();
            Font font = this.workbook.createFont();
            font.setFontHeightInPoints(12);
            titleStyle.setFont(font);
            titleStyle.setAlignment(2);
            titleStyle.setVerticalAlignment(1);
            return titleStyle;
        }

        public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp)
        {
            CellStyle style = workbook.createCellStyle();
            style.setAlignment(2);
            style.setVerticalAlignment(1);
            style.setDataFormat(STRING_FORMAT);
            if (isWarp) {
                style.setWrapText(true);
            }
            return style;
        }
    }